package com.jlz.actions.c;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Standard;
import org.springframework.beans.factory.annotation.Autowired;

import com.jlz.managers.core.Categories;
import com.julewa.TODO;

@Standard(rest="id")
public class IndexAction { 
	@Autowired Categories categories;
	//
	private Long id = null;
	//
	public String execute(){
		selectCategory();
		return "category";
	}
	
	@Action("test")
	public String doAnything(){
		throw new TODO();
	}
	
	private boolean selectCategory(){
		if(id != null){
			categories.setCurrentCategory(id);
			return true;
		}else{//others
			return false;
		}
	}
	
	@Action("select")
	public String ajaxSelect(){
		selectCategory();
		return "category.ajax";
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}
	
	
	
}
